package cn.edu.nhic.service;

import cn.edu.nhic.dao.UserDao;
import cn.edu.nhic.entity.User;

/**
 * @Description
 * @Date 2024/9/14 15:10
 * @Created by dwp
 */
public class CheckService {
    private CheckService(){
    }
    private static CheckService checkService;

    static {
        checkService = new CheckService();
    }
    public boolean checkLogin(User user) {
        String userName = user.getUserName();
        String password = user.getPassword();

        if (userName == null || userName.isEmpty()) {
            return false;
        }

        if (password == null || password.isEmpty()) {
            return false;
        }
        // user data access object
        UserDao userDao = UserDao.getUserDao();
        return userDao.selectUser(user);
    }

    public static CheckService getCheckService() {
        return checkService;
    }
}
